package com.yyx.beautifylib.model;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

import com.yyx.beautifylib.ui.activity.BLMosaicActivity;
import com.yyx.beautifylib.utils.ActivityUtils;
/**
 * @Desc:马赛克参数类
 * @Author:  86133
 * @Time:  2020/4/11
 */
public class BLMosaicParam implements Parcelable {
    public static final String KEY = "mosaic";
    public static final int REQUEST_CODE_MOSAIC = 0x0110;
    private String path;
    public static Bitmap bitmap;

    public BLMosaicParam(){}

    public BLMosaicParam(String path) {
        this.path = path;
    }


    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public static void recycleBitmap(){
        if (bitmap != null){
            bitmap.recycle();
            bitmap = null;
        }
    }

    public static void startActivity(Activity activity, BLMosaicParam param){
        Intent intent = new Intent(activity, BLMosaicActivity.class);
        intent.putExtra(BLMosaicParam.KEY, param);
        ActivityUtils.startActivityForResult(activity, intent, BLMosaicParam.REQUEST_CODE_MOSAIC);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.path);
    }

    protected BLMosaicParam(Parcel in) {
        this.path = in.readString();
    }

    public static final Creator<BLMosaicParam> CREATOR = new Creator<BLMosaicParam>() {
        @Override
        public BLMosaicParam createFromParcel(Parcel source) {
            return new BLMosaicParam(source);
        }

        @Override
        public BLMosaicParam[] newArray(int size) {
            return new BLMosaicParam[size];
        }
    };
}
